﻿{% extends 'task_market/base.html' %}
{% load static %}
{% block title %}
    个人主页
{% endblock %}
{% block content %}

    <div class="breadcrumbs">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="bread-inner">
                        <ul class="bread-list">
                            <li><a href="{% url 'task_market:index' %}" target="_blank">主页<i
                                    class="ti-arrow-right"></i></a></li>
                            <li class="active"><a href="#">{{ name }}的个人主页</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <div class="container mt-4 mx-auto">
        <div class="row">
            <div class="col-lg-12">
                <div class="account-content">
                    <h4 class="account-content-title"><i class="far fa-user"></i> 个人信息</h4>
                    <div class="profile-info">
                        <div class="row">
                            <div class="col-lg-5 mb-1">
                                <div class="profile-sidebar">
                                    <img src="{% static 'temp_shop/assets/img/products/review.jpg' %}" alt="">
                                    <div class="profile-title">
                                        <div>
                                            <h5>{{ name }}</h5>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-7">
                                <div class="row">
                                    <div class="col-lg-4 mb-1 mx-auto">
                                        <div class="profile-widget">
                                            <b>{{ money|floatformat:2 }}</b>
                                            <p>账户金额</p>
                                        </div>
                                    </div>
                                    {% if user_type == 1 %}
                                        <div class="col-lg-4 mb-1 mx-auto">
                                            <div class="profile-widget">
                                                {% if score|stringformat:"s" == '0.0' %}
                                                    <b>100.000</b>
                                                {% else %}
                                                    <b>{{ score }}</b>
                                                {% endif %}
                                                <p>用户得分</p>
                                            </div>
                                        </div>
                                    {% elif user_type == 2 %}
                                        <div class="col-lg-4 mb-1 mx-auto">
                                            <div class="profile-widget">
                                                <b>80</b>
                                                <p>today</p>
                                            </div>
                                        </div>
                                    {% endif %}
                                    <form method="POST" action="{% url 'task_market:user_mng:self' %}">
                                        {% csrf_token %}
                                        <div class="col-lg-4 mb-1">
                                            <div class="profile-widget">
                                                输入充值金额<input type="number" name="user_money" step="0.01"
                                                                   value="{{ request.user.user_money }}">
                                                <button type="submit">提交</button>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {% if user_type == 2 %}
        <div>
            <div class="container mt-4">
                <div>
                    <div class="col-lg-12">
                        <div class="account-content">
                            <h4 class="account-content-title"><i class="far fa-layer-group"></i> 选择服务</h4>
                            <div class="col-lg-6 mx-auto">

                                <div class="layui-btn-container d-flex justify-content-center">
                                    <a class="layui-btn layui-btn-radius mx-4" href="{% url 'task_con:adddata' %}"
                                       style="color: #ffffff;">上传数据</a>
                                    <a href="{% url 'task_con:addfile' %}" type="button"
                                       class="layui-btn layui-btn-radius mx-2"
                                       style="color: #ffffff;">添加项目</a>
                                    {#                                    <a href="{% url 'task_con:findfile' %}" type="button"#}
                                    {#                                       class="layui-btn layui-btn-radius mx-2"#}
                                    {#                                       style="color: #ffffff;">查询项目</a>#}
                                </div>


                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    {% endif %}
    <section>
        <div class="container mt-4">
            <div class="row">
                <div class="col-lg-12 ">
                    <div class="account-content">
                        <h4 class="account-content-title"><i class="far fa-shopping-bag"></i>任务列表</h4>
                        <div class="account-content-table">
                            <div class="table-responsive">
                                <table class="table table-borderless">
                                    <tr>
                                        <th>任务编号</th>
                                        <th>发布者ID</th>
                                        <th>任务描述</th>
                                        <th>任务状态</th>
                                        <th>截至时间</th>
                                        {% if user_type == 1 %}
                                            <th>标注</th>
                                        {% elif user_type == 2 %}
                                            <th>操作</th>
                                        {% endif %}

                                    </tr>

                                    {% for task in all_task %}

                                        {% if task.id|stringformat:"s" in apply_task_id %}

                                            <tr class="account-order-list">
                                                <td><b>{{ task.id }}</b></td>
                                                <td>{{ task.task_publish_id|truncatechars:8 }}</td>
                                                <td>{{ task.task_description }}</td>
                                                {% if task.task_status == 0 %}
                                                    <td><span class="badge bg-primary">待审核</span></td>
                                                {% elif task.task_status == 1 %}
                                                    <td><span class="badge bg-secondary">进行中</span></td>
                                                {% elif task.task_status == 2 %}
                                                    <td><span class="badge bg-success">已终止</span></td>
                                                {% elif task.task_status == 3 %}
                                                    <td><span class="badge bg-danger">未通过</span></td>
                                                {% elif task.task_status == 4 %}
                                                    <td><span class="badge bg-danger">终止中</span></td>
                                                {% endif %}
                                                <td>{{ task.task_deadline_time|date:"Y年m月d日" }}</td>
                                                {% if user_type == 1 and task.task_status == 1 %}
                                                    <td>
                                                        <div>
                                                            <a href="{% url 'annotating_data:index' task_id=task.id %}"
                                                               class="content-action content-action-mr mx-auto"><i
                                                                    class="far fa-pen"> 标注</i></a><!--等会改-->
                                                        </div>
                                                    </td>
                                                {% elif user_type == 1 %}
                                                    <td>
                                                        <div>
                                                            <a href="#"
                                                               class="content-action content-action-mr mx-auto"><i
                                                                    class="far"> 无</i></a><!--等会改-->
                                                        </div>
                                                    </td>
                                                {% elif user_type == 2 and task.task_status == 2 %}
                                                    <td>
                                                        <div>
                                                            <a href="{% url 'task_market:user_mng:download' task_id=task.id %}"
                                                               class="content-action content-action-mr mx-auto"><i
                                                                    class="far fa-download"> 下载</i></a><!--等会改-->
                                                        </div>
                                                    </td>
                                                {% elif user_type == 2 and task.task_status == 1 %}
                                                    <td>
                                                        <div>
                                                            <a href="{% url 'task_market:user_mng:end' task_id=task.id %}"
                                                               class="content-action content-action-mr mx-auto"><i
                                                                    class="far fa-hourglass-end"> 发起终止</i></a>
                                                            <!--等会改-->
                                                        </div>
                                                    </td>
                                                {% elif user_type == 2 %}
                                                    <td>
                                                        <div>
                                                            <a href="#"
                                                               class="content-action content-action-mr mx-auto"><i
                                                                    class="far"> 无</i></a>
                                                            <!--等会改-->
                                                        </div>
                                                    </td>
                                                {% endif %}
                                            </tr>
                                        {% endif %}
                                    {% endfor %}
                                </table>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <div style="margin-top: 100px;"></div>

{% endblock %}

